package week2nd;

public class LinkedListExample {
    public static void main(String[] args) {
        Student student = new Student("赵乾宸", 20172316, "睡觉");
        Student Head = student;
        PrintLinkedList(Head);

        Student student1 = new Student("asd", 123, "asd");
        InsertNode(student, student1);
    }

    public static void PrintLinkedList(Student Head){
        Student node = Head;
        while (node != null) {
            System.out.println("姓名:" + node.name + "\t学号:" + node.number + "\t爱好:" + node.hobby);
            node = node.next;
        }
    }

    public static void InsertNode(Student Head, Student node){
        Student temp = Head;
        if (Head != null) {
            while (temp.next != null) {
                temp = temp.next;
            }
            temp.next = node;
        }
        else {
            Head = node;
        }
    }
}
